home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 November / Chip Kasım 2000.iso / prog / basic / 09 / AXA2.CAB / DAJAVA.CAB / com / ms / dxmedia / DXMCanvas.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-10-14  |  1.1 KB  |  79 lines

  1. package com.ms.dxmedia;
  2.  
  3. public class DXMCanvas extends DXMCanvasBase implements Runnable {
  4.    private Thread _thread;
  5.    private boolean _showing = true;
  6.  
  7.    public synchronized void removeModel() {
  8.       if (this._thread != null) {
  9.          this._thread.stop();
  10.  
  11.          try {
  12.             this._thread.join();
  13.          } catch (InterruptedException var1) {
  14.          }
  15.  
  16.          this._thread = null;
  17.          ((DXMCanvasBase)this).stopModel();
  18.       }
  19.  
  20.    }
  21.  
  22.    public synchronized void hideModel() {
  23.       if (this._showing && this._thread != null) {
  24.          this._thread.suspend();
  25.          this._showing = false;
  26.       }
  27.  
  28.    }
  29.  
  30.    public synchronized void addModel() {
  31.       if (this._thread == null) {
  32.          try {
  33.             ((DXMCanvasBase)this).startModel();
  34.          } catch (DXMException var3) {
  35.             ((DXMCanvasBase)this).stopModel();
  36.             throw var3;
  37.          }
  38.  
  39.          this._thread = new Thread(this);
  40.          if (!this._showing) {
  41.             this._thread.suspend();
  42.          }
  43.  
  44.          this._thread.start();
  45.       }
  46.  
  47.    }
  48.  
  49.    public void run() {
  50.       Thread.currentThread().setPriority(1);
  51.  
  52.       while(true) {
  53.          try {
  54.             ((DXMCanvasBase)this).tick();
  55.  
  56.             try {
  57.                Thread.sleep(0L);
  58.             } catch (InterruptedException var1) {
  59.             }
  60.          } catch (DXMException var2) {
  61.             this.removeModel();
  62.             return;
  63.          }
  64.       }
  65.    }
  66.  
  67.    protected Thread GetThread() {
  68.       return this._thread;
  69.    }
  70.  
  71.    public synchronized void showModel() {
  72.       if (!this._showing && this._thread != null) {
  73.          this._thread.resume();
  74.          this._showing = true;
  75.       }
  76.  
  77.    }
  78. }
  79.